<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <style>
        .container {
            width: 800px;
            margin: 50px auto;
            padding: 20px;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }
        .welcome {
            font-size: 24px;
        }
        .btn-logout {
            padding: 8px 15px;
            background-color: #dc3545;
            color: white;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="welcome">欢迎, <span id="nickname"></span></div>
            <button class="btn-logout" onclick="logout()">退出登录</button>
        </div>
    </div>

    <script>
		document.addEventListener('DOMContentLoaded', function() {
		            const userInfo = JSON.parse(localStorage.getItem('userInfo'));
					console.log(userInfo)
		            if (userInfo && userInfo.nickname) {
		                document.getElementById('nickname').textContent = userInfo.nickname;
		            } else {
		                window.location.href = '/login';
		            }
		        });
		
		        function logout() {
		            localStorage.removeItem('token');
		            localStorage.removeItem('userInfo');
		            window.location.href = '/login';
		        }
    </script>
</body>
</html> 